/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Reservas;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author RODRIGO
 */
public class MiRender extends DefaultTableCellRenderer {

    Color background;
    Color foreground;

    public MiRender(Color background, Color foreground) {
        super();
        this.background = background;
        this.foreground = foreground;
    }
    
    
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if (value instanceof String) {
            String estado = (String) value;
            if (estado.equals("Libre")) {
                cell.setBackground(Color.GREEN);
                cell.setForeground(Color.WHITE);
            } else {
                if (estado.equals("Reservado")) {
                    cell.setBackground(Color.RED);
                    cell.setForeground(Color.WHITE);
                }
            }
        }
        return cell;
    }
}
